# Copyright (c) 2017 Presto Labs Pte. Ltd.
# Author: inkyu

from coin.exchange.base.kr_rest.py_product import PyProduct
from coin.exchange.shared.kr_rest.product import SharedProduct

from coin.exchange.binance.kr_rest.product import BinanceProduct
from coin.exchange.bitfinex_v2.kr_rest.product import BitfinexProduct
from coin.exchange.bitflyer_v1.kr_rest.futures_product import BitflyerFuturesProduct
from coin.exchange.bithumb.kr_rest.product import BithumbProduct
from coin.exchange.bitmex.kr_rest.futures_product import BitmexFuturesProduct
from coin.exchange.fcoin.kr_rest.product import FcoinProduct
from coin.exchange.hitbtc_v2.kr_rest.product import HitbtcProduct
from coin.exchange.bequant_v2.kr_rest.product import BequantProduct
from coin.exchange.huobi.kr_rest.product import HuobiProduct
from coin.exchange.huobi_futures.kr_rest.futures_product import HuobiFuturesProduct
from coin.exchange.kraken.kr_rest.product import KrakenProduct
from coin.exchange.kraken_futures.kr_rest.futures_product import KrakenFuturesProduct
from coin.exchange.okex.kr_rest.product import OkexProduct
from coin.exchange.okex_futures.kr_rest.futures_product import OkexFuturesProduct
from coin.exchange.quoinex_v2.kr_rest.product import QuoinexProduct
from coin.exchange.upbit_v1.kr_rest.product import UpbitProduct
from coin.exchange.gdax.kr_rest.product import GdaxProduct
from coin.exchange.bitstamp_v2.kr_rest.product import BitstampProduct
from coin.exchange.korbit_v1.kr_rest.product import KorbitProduct
from coin.exchange.coinone_v2.kr_rest.product import CoinoneProduct
from coin.exchange.deribit_v1.kr_rest.futures_product import DeribitFuturesProduct
from coin.exchange.gopax.kr_rest.product import GopaxProduct
from coin.exchange.binance_futures.kr_rest.futures_product import BinanceFuturesProduct
from coin.exchange.bybit.kr_rest.futures_product import BybitFuturesProduct
from coin.exchange.ftx.kr_rest.product import FTXProduct
from coin.exchange.ftx_futures.kr_rest.futures_product import FTXFuturesProduct
from coin.exchange.prex_futures.kr_rest.futures_product import PrexFuturesProduct
from coin.exchange.uniswap_v3.kr_rest.product import UniswapProduct
from coin.exchange.uniswap_v2.kr_rest.product import UniswapProduct as UniswapV2Product

import coin.exchange.binance.kr_rest.product_info as binance_product_info
import coin.exchange.bitfinex_v2.kr_rest.product_info as bitfinex_product_info
import coin.exchange.bitflyer_v1.kr_rest.product_info as bitflyer_product_info
import coin.exchange.bithumb.kr_rest.product_info as bithumb_product_info
import coin.exchange.bitmex.kr_rest.product_info as bitmex_product_info
import coin.exchange.fcoin.kr_rest.product_info as fcoin_product_info
import coin.exchange.hitbtc_v2.kr_rest.product_info as hitbtc_product_info
import coin.exchange.bequant_v2.kr_rest.product_info as bequant_product_info
import coin.exchange.huobi.kr_rest.product_info as huobi_product_info
import coin.exchange.huobi_futures.kr_rest.product_info as huobi_futures_product_info
import coin.exchange.kraken.kr_rest.product_info as kraken_product_info
import coin.exchange.kraken_futures.kr_rest.product_info as kraken_futures_product_info
import coin.exchange.okex.kr_rest.product_info as okex_product_info
import coin.exchange.okex_futures.kr_rest.product_info as okex_futures_product_info
import coin.exchange.quoinex_v2.kr_rest.product_info as quoinex_product_info
import coin.exchange.upbit_v1.kr_rest.product_info as upbit_product_info
import coin.exchange.gdax.kr_rest.product_info as gdax_product_info
import coin.exchange.bitstamp_v2.kr_rest.product_info as bitstamp_product_info
import coin.exchange.korbit_v1.kr_rest.product_info as korbit_product_info
import coin.exchange.coinone_v2.kr_rest.product_info as coinone_product_info
import coin.exchange.deribit_v2.kr_rest.product_info as deribit_futures_product_info
import coin.exchange.gopax.kr_rest.product_info as gopax_product_info
import coin.exchange.binance_futures.kr_rest.product_info as binance_futures_product_info
import coin.exchange.bybit.kr_rest.product_info as bybit_futures_product_info
import coin.exchange.ftx.kr_rest.product_info as ftx_product_info
import coin.exchange.ftx_futures.kr_rest.product_info as ftx_futures_product_info
import coin.exchange.prex_futures.kr_rest.product_info as prex_futures_product_info
import coin.exchange.bitbank.kr_rest.product_info as bitbank_product_info
import coin.exchange.lmax_digital.kr_rest.product_info as lmaxdigital_product_info
import coin.exchange.kucoin.kr_rest.product_info as kucoin_product_info
import coin.exchange.kucoin_futures.kr_rest.product_info as kucoin_futures_product_info
import coin.exchange.phemex.kr_rest.product_info as phemex_product_info
import coin.exchange.phemex_futures.kr_rest.product_info as phemex_futures_product_info
import coin.exchange.uniswap_v3.kr_rest.product_info as uniswap_v3_product_info
import coin.exchange.uniswap_v2.kr_rest.product_info as uniswap_v2_product_info


product_holder_map = {
  ('Futures', 'Binance'): binance_futures_product_info,
  ('Futures', 'Bitflyer'): bitflyer_product_info,
  ('Futures', 'Bitmex'): bitmex_product_info,
  ('Futures', 'Bybit'): bybit_futures_product_info,
  ('Futures', 'Deribit'): deribit_futures_product_info,
  ('Futures', 'Ftx'): ftx_futures_product_info,
  ('Futures', 'Huobi'): huobi_futures_product_info,
  ('Futures', 'Kraken'): kraken_futures_product_info,
  ('Futures', 'Kucoin'): kucoin_futures_product_info,
  ('Futures', 'Okex'): okex_futures_product_info,
  ('Futures', 'Phemex'): phemex_futures_product_info,
  ('Futures', 'Prex'): prex_futures_product_info,
  ('Spot', 'Bequnt'): bequant_product_info,
  ('Spot', 'Binance'): binance_product_info,
  ('Spot', 'Bitbank'): bitbank_product_info,
  ('Spot', 'Bithumb'): bithumb_product_info,
  ('Spot', 'Bitstamp'): bitstamp_product_info,
  ('Spot', 'Coinone'): coinone_product_info,
  ('Spot', 'Ftx'): ftx_product_info,
  ('Spot', 'Gdax'): gdax_product_info,
  ('Spot', 'Huobi'): huobi_product_info,
  ('Spot', 'Korbit'): korbit_product_info,
  ('Spot', 'Kraken'): kraken_product_info,
  ('Spot', 'Kucoin'): kucoin_product_info,
  ('Spot', 'Lmaxdigital'): lmaxdigital_product_info,
  ('Spot', 'Okex'): okex_product_info,
  ('Spot', 'Phemex'): phemex_product_info,
  ('Spot', 'Quoinex'): quoinex_product_info,
  ('Spot', 'Upbit'): upbit_product_info
}

def get_holder_from_product(product):
  assert not isinstance(product, SharedProduct), product

  if isinstance(product, BinanceProduct):
    return binance_product_info.get_holder_from_product(product)
  elif isinstance(product, BitfinexProduct):
    return bitfinex_product_info.get_holder_from_product(product)
  elif isinstance(product, HuobiProduct):
    return huobi_product_info.get_holder_from_product(product)
  elif isinstance(product, HuobiFuturesProduct):
    return huobi_futures_product_info.get_holder_from_product(product)
  elif isinstance(product, OkexProduct):
    return okex_product_info.get_holder_from_product(product)
  elif isinstance(product, OkexFuturesProduct):
    return okex_futures_product_info.get_holder_from_product(product)
  elif isinstance(product, BitflyerFuturesProduct):
    return bitflyer_product_info.get_holder_from_product(product)
  elif isinstance(product, KrakenProduct):
    return kraken_product_info.get_holder_from_product(product)
  elif isinstance(product, KrakenFuturesProduct):
    return kraken_futures_product_info.get_holder_from_product(product)
  elif isinstance(product, FcoinProduct):
    return fcoin_product_info.get_holder_from_product(product)
  elif isinstance(product, UpbitProduct):
    return upbit_product_info.get_holder_from_product(product)
  elif isinstance(product, BithumbProduct):
    return bithumb_product_info.get_holder_from_product(product)
  elif isinstance(product, BitmexFuturesProduct):
    return bitmex_product_info.get_holder_from_product(product)
  elif isinstance(product, QuoinexProduct):
    return quoinex_product_info.get_holder_from_product(product)
  elif isinstance(product, HitbtcProduct):
    return hitbtc_product_info.get_holder_from_product(product)
  elif isinstance(product, BequantProduct):
    return bequant_product_info.get_holder_from_product(product)
  elif isinstance(product, GdaxProduct):
    return gdax_product_info.get_holder_from_product(product)
  elif isinstance(product, BitstampProduct):
    return bitstamp_product_info.get_holder_from_product(product)
  elif isinstance(product, KorbitProduct):
    return korbit_product_info.get_holder_from_product(product)
  elif isinstance(product, CoinoneProduct):
    return coinone_product_info.get_holder_from_product(product)
  elif isinstance(product, DeribitFuturesProduct):
    return deribit_futures_product_info.get_holder_from_product(product)
  elif isinstance(product, GopaxProduct):
    return gopax_product_info.get_holder_from_product(product)
  elif isinstance(product, BinanceFuturesProduct):
    return binance_futures_product_info.get_holder_from_product(product)
  elif isinstance(product, BybitFuturesProduct):
    return bybit_futures_product_info.get_holder_from_product(product)
  elif isinstance(product, FTXProduct):
    return ftx_product_info.get_holder_from_product(product)
  elif isinstance(product, FTXFuturesProduct):
    return ftx_futures_product_info.get_holder_from_product(product)
  elif isinstance(product, PrexFuturesProduct):
    return prex_futures_product_info.get_holder_from_product(product)
  elif isinstance(product, UniswapProduct):
    return uniswap_v3_product_info.get_holder_from_product(product)
  elif isinstance(product, UniswapV2Product):
    return uniswap_v2_product_info.get_holder_from_product(product)
  elif isinstance(product, PyProduct):
    return product.product_holder
  else:
    raise ValueError(product)
